﻿<%@ Control Language="C#" AutoEventWireup="true" Inherits="System.Web.Mvc.ViewUserControl<Veteran_cms.Models.HomeAdminListViewModel>" %>
<%@ Import Namespace="THS.HtmlHelpers" %>
<div class="widget">
    <div class="title">
        <span class="titleIcon"><input type="checkbox" id="titleCheck" name="titleCheck" /></span><h6>Danh sách Ban quản trị</h6>
        <div style="float:right"><a href="<%=Url.Action("Create","ManageAdmin") %>" title="" class="button colorpicker_slider" style="margin: 5px;"><img src="../../Images/adminSite/icons/dark/add.png" alt="" class="icon" /><span>THÊM MỚI</span></a></div>
    </div>
    <table cellpadding="0" cellspacing="0" width="100%" class="sTable withCheck mTable" id="checkAll">
        <thead>
            <tr>
                <td><img src="../../Images/adminSite/icons/tableArrows.png" alt="" /></td>
                <td style="width:50%" class="sortCol"><div>Tên đăng nhập<span></span></div></td>
                <td> Cho phép đăng nhập</td>
                <td> Loại</td>
                <td>Chức năng</td>
            </tr>
        </thead>
        <tfoot>
            <tr>
                <td colspan="6">
                   <div class="tPagination">
                        <%if (Model != null)
                          { %>
                        <%=Ajax.Pager(Model.AdminInfo.CurrentPage, Model.AdminInfo.TotalItems, "AdmintList", 0, Model.AdminInfo.ItemsPerPage, "Paging")%>
                        <%} %>
                    </div>
                </td>
            </tr>
        </tfoot>
        <tbody>
        <%if (Model.AdminList != null)
          {
              foreach (var item in Model.AdminList)
              {%>
            <tr>
                <td><input type="checkbox" id="titleCheck2" name="checkRow" /></td>
                
                <td><a href="<%=Url.Action("Details", "ManageAdmin", new {id = item.admin_id}) %>" title=""><%=item.username %></a></td>
                <td><%=Html.CheckBox("AllowLogOn", item.allow_logon, new { onclick = "AllowLogon('" + item.admin_id + "')" })%></td>
                <td><%=item.type %></td>
                <td class="actBtns">
                    <a href="<%=Url.Action("Details", "ManageAdmin", new {id = item.admin_id}) %>" title="Cập nhật" class="tipS"><img src="../../Images/adminSite/icons/dark/pencil.png" alt="" /></a>
                    <a href="<%=Url.Action("Delete", "ManageAdmin", new {id = item.admin_id}) %>" title="Xóa" class="tipS" onclick="return ConfirmAdmin('<%=item.username %>')"><img src="../../Images/adminSite/icons/uploader/deleteFile.png" alt=""/></a>
                </td>
            </tr>
            <%}
          } %>
        </tbody>
    </table>
</div>
 <script type="text/javascript">

     function ConfirmAdmin(usn) {
         if (usn.toString() == "Admin" || usn.toString() == "admin") {
             alert("Không cho phép xóa admin");
             return false;
         }
         else {
             if (confirm("Bạn chắc chắn xóa?") == true) {
                 return true;
             }
             else {
                 return false;
             } 
         }
     }
     function AllowLogon(id) {
         $.post("/ManageAdmin/AllowLogOn", { id: id });
     }

 </script>